package br.com.gsc.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import br.com.gsc.model.tableMapping.Company;
import br.com.gsc.repository.objRepos.CompanyRepository;


@Controller
@RequestMapping("/empresas")
public class CompaniesController {

	@Autowired
	CompanyRepository cRepo;

	@RequestMapping(value="/empresas",method = RequestMethod.GET)
	public ModelAndView getEmpresas(){
		ModelAndView model = new ModelAndView("empresas");
		List<Company> list = cRepo.findAll();
		model.addObject("companies",list);	
		return model;	
	}
	
}
